/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kimstore.gui.sales;

import com.kimstore.bean.Item;
import com.kimstore.bean.Product;
import com.kimstore.factory.DaoFactory;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class SelectItemControllerX {

    private List<Item> items;
    private SelectItemWindowX selectItemWindow;
    private AddItemToOrderController addItemController;

    public SelectItemControllerX(AddItemToOrderController addItemController) {
        this.addItemController = addItemController;
    }

    public void displayWindow() {
        this.items = DaoFactory.getInstance().getItemDao().getAllAvailableItems();
        
        if(addItemController.getAllSelectedItems() != null)
            items.removeAll(addItemController.getAllSelectedItems());

        selectItemWindow = new SelectItemWindowX(this);
        selectItemWindow.populateTable(items);
        selectItemWindow.displayWindow();
    }

    public void fromWindow(String sku) {
        addItemController.createSelectItemControllerCallback(DaoFactory.getInstance().getItemDao().findBySerial(sku));

    }
}
